package com.woniu.web.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.woniu.domain.Stu;
import com.woniu.service.StuService;
import com.woniu.service.impl.StuServiceImpl;

/**
 * Servlet implementation class FindStuServlet
 */
@WebServlet("/FindStuServlet")
public class FindStuServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FindStuServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Integer sId = Integer.parseInt(request.getParameter("sId"));
		System.out.println("sId:\t"+sId);
		StuService ss = new StuServiceImpl();
		Stu stu = null;
		try {
			stu = ss.findStu(sId);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		request.setAttribute("stu", stu);
		request.getRequestDispatcher("UpdateStu.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
